﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Streambolics.App
{
    public partial class StatusAppForm : Streambolics.App.AppForm
    {
        private StringList _Messages = new StringList ();

        public StatusAppForm ()
        {
            InitializeComponent ();
        }

        #region Inherited Event Handlers

        protected override void OnLoad (EventArgs e)
        {
            base.OnLoad (e);
            GlobalLog.EventLogged += new GlobalLogEventHandler (GlobalLog_EventLogged);
        }

        #endregion

        #region Component Event Handlers

        void GlobalLog_EventLogged (object sender, GlobalLogEventArgs e)
        {
            _Messages.Add (e.ToString ());
            while (_Messages.Count > 10)
            {
                _Messages.RemoveAt (0);
            }
            statusLabel_Log.Text = e.Message;
            statusLabel_Log.ToolTipText = _Messages.Text;

            if (e.Severity >= GlobalLogSeverity.Warning)
            {
                statusLabel_Log.BackColor = Color.Bisque;
            }
            else
            {
                statusLabel_Log.BackColor = SystemColors.Control;
            }
        }

        private void statusLabel_Log_DoubleClick (object sender, EventArgs e)
        {
        }

        private void contextMenu_Status_ModuleExplorer_Click (object sender, EventArgs e)
        {
            Streambolics.App.Gpl.MainHooks.OlvObserveModule (MasterComputingModule.MasterModule);
        }
        #endregion

    }
}
